<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
});
</script>
<?if (isset($categories)):?>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.gvchart.js"></script>
<script type="text/javascript">
gvChartInit();
$(function(){
	$("#barchart").gvChart({
		chartType: 'BarChart',
		gvSettings: {
			vAxis: {title: '分类'},
			hAxis: {title: '数量'},
			width: 950,
			height: 700
		}
	});
	$("#piechart").gvChart({
		chartType: 'PieChart',
		gvSettings: {
			width: 950,
			height: 500
		}
	});
});
</script>
<?endif;?>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>日期</th>
	<td>
		<input type="text" name="begin_date" value="<?=isset($_GET['begin_date'])?$_GET['begin_date']:''?>" class="datepicker" /> to 
		<input type="text" name="end_date" value="<?=isset($_GET['end_date'])?$_GET['end_date']:''?>" class="datepicker" />
	</td>
</tr>
<tr>
	<td><input type="hidden" name="is_search" value="1" /></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<?if (isset($categories)):?>
<table id="barchart">
<caption>销售分析 - 依采购分类</caption>
<thead>
<tr>
	<th></th>
	<?foreach ($categories as $c):?>
	<th><?=$c['name']?></th>
	<?endforeach;?>
</tr>
</thead>
<tbody>
<tr>
	<th></th>
	<?foreach ($categories as $c):?>
	<td><?=$c['count']?></td>
	<?endforeach;?>
</tr>
</tbody>
</table>

<table id="piechart">
<caption>销售分析 - 依采购分类 （饼状图）</caption>
<thead>
<tr>
	<th></th>
	<?foreach ($categories as $c):?>
	<th><?=$c['name']?></th>
	<?endforeach;?>
</tr>
</thead>
<tbody>
<tr>
	<th></th>
	<?foreach ($categories as $c):?>
	<td><?=$c['count']?></td>
	<?endforeach;?>
</tr>
</tbody>
</table>
<?endif;?>
<?php $this->_endblock();?>